package com.ssmdemo.utils;

public class Result<T> {

    private T data;

    private String message;

    private Integer code;

    public Result(){}

    public Result(T data, String message, Integer code) {
        this.data = data;
        this.message = message;
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static <T> Result<T> success(T data){
        Result result=new Result();
        result.setCode(ResultEnum.SUCCESS);
        result.setData(data);
        result.setMessage(ResultMessage.SUCCESS);
        return result;
    }

    public static <T> Result<T> error(){
        Result result=new Result();
        result.setCode(ResultEnum.ERROR);
        result.setMessage(ResultMessage.FAIL);
        return result;
    }
}
